package com.stan.core.spark.ad.blackList.functions;

import com.google.common.base.Optional;
import org.apache.spark.api.java.function.Function;
import scala.Serializable;
import scala.Tuple2;

public class UserId2DataAndBlackFunction
        implements Function<Tuple2<String, Tuple2<String, Optional<Boolean>>>, Boolean>, Serializable {
    public Boolean call(Tuple2<String, Tuple2<String, Optional<Boolean>>>
                                stringTuple2Tuple2) throws Exception {
        boolean result = true;
        Optional<Boolean> isInBlackList = stringTuple2Tuple2._2._2;
        if(isInBlackList.isPresent() && isInBlackList.get() == true){
            result  = false;
        }
        return result;
    }
}
